package com.wclass.common;

import com.google.common.base.Charsets;

/**
 * Created by zhurusen on 2018/6/9
 */
public class DigestUtils  extends org.springframework.util.DigestUtils {

    /**
     * Calculates the MD5 digest and returns the value as a 32 character hex
     * string.
     *
     * @param data
     *            Data to digest
     * @return MD5 digest as a hex string
     */
    public static String md5Hex(final String data) {
        return DigestUtils.md5DigestAsHex(data.getBytes(Charsets.UTF_8));
    }

    /**
     * Return a hexadecimal string representation of the MD5 digest of the given
     * bytes.
     *
     * @param bytes
     *            the bytes to calculate the digest over
     * @return a hexadecimal digest string
     */
    public static String md5Hex(final byte[] bytes) {
        return DigestUtils.md5DigestAsHex(bytes);
    }

    public static void main(String[] args) {
        System.out.println(md5Hex("tdxjcyj55?/!"));
    }
}
